package cuiyt.juc.bq.arrayblockingqueue;

import java.util.concurrent.ArrayBlockingQueue;

/**
 * @author cyt
 * @create 2020-09-16 下午 3:08
 */
public class demo1 {
    /**
     * 阻塞队列
     * <p>
     * 会抛出异常
     * java.lang.IllegalStateException: Queue full
     * <p>
     * java.util.NoSuchElementException
     *
     * @param args
     */
    public static void main(String[] args) {
        ArrayBlockingQueue<Object> queue = new ArrayBlockingQueue<>(3);
        queue.add(1);
        queue.add(2);
        queue.add(3);
        queue.add(4);
        System.out.println(queue.remove());
        System.out.println(queue.remove());
        System.out.println(queue.remove());
        System.out.println(queue.remove());
    }
}
